package visitor;


import java.util.Iterator;

public class ListVisitor implements Visitor {
	
	private String currentDirectory = "";

	public void visitor(File file) {
		System.out.println(currentDirectory + "/" + file);
	}

	public void visitor(Directory directory) {
		System.out.println(currentDirectory + "/" + directory);
		String saveDir = currentDirectory;
		currentDirectory = currentDirectory + "/" + directory.getName();
		Iterator iterator = directory.iterator();
		while (iterator.hasNext()) {
			Entry entry = (Entry) iterator.next();
			entry.accept(this);
		}
		currentDirectory = saveDir;
	}

}
